package com.augurit.common.dao;

import org.springframework.stereotype.Repository;

import com.augurit.common.base.dao.BaseDao;
import com.augurit.common.entity.AtServerConvert;
import com.augurit.common.system.web.org.form.AtServerConvertForm;

/**
 * WEB服务器外网地址转换DAO类
 */
@Repository
public class AtServerConvertDao extends BaseDao<AtServerConvert, Long> {

	public AtServerConvertForm getForm(Long id){
		AtServerConvertForm form = null;
		
		if(id != null){
			AtServerConvert entity = this.get(id);
//			if(entity != null)
//				form = (AtServerConvertForm)DozerUtils.map(entity, AtServerConvertForm.class);
		}

		return form;
	}
	
	/**
	 * 保存WEB服务器外网地址转换Form对象
	 * @param form WEB服务器外网地址转换Form对象
	 */
	public void save(AtServerConvertForm form){
		
		if(form != null){
			AtServerConvert entity = null;
			
			//准备VO对象
			if(form != null && form.getConvertId() != null && form.getConvertId().intValue() > 0){
				entity = this.get(form.getConvertId());
			}else{
				form.setConvertId(null);
				entity = new AtServerConvert();
			}
			
			//属性值转换
//			DozerUtils.map(form, entity);
			
			//保存
			super.save(entity);
			
			//回填ID属性值
			form.setConvertId(entity.getConvertId());
		}
	}

}
